package cn.eastseven.netserver;

import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {

	private static final Logger log = LoggerFactory.getLogger(Main.class);

	public static void main(String[] args) {
		log.info("start...");
		final ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:application.xml");
		log.info("{}", ctx);
		
		Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
			public void run() {
				NioSocketAcceptor ioAcceptor = (NioSocketAcceptor) ctx.getBean("ioAcceptor");
				ioAcceptor.unbind();
				log.info("shutdown...");
			}
		}));
		
	}

}
